package com.color.admin.log.controller;


import com.color.admin.common.core.base.BaseController;
import com.color.admin.common.core.constant.Constant;
import com.color.admin.common.core.page.PageRequest;
import com.color.admin.common.core.result.ResultData;
import com.color.admin.log.entity.SysLog;
import com.color.admin.log.entity.query.LogCriteria;
import com.color.admin.log.service.LogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author HaiQiu
 * @date 2022/1/24
 */
@Tag(name = "日志管理",description = "日志管理接口")
@RestController
@RequestMapping("/syslog/log")
public class LogController extends BaseController {

    @Autowired
    private LogService logService;

    @PostMapping("/save")
    @Operation(summary = "新增日志",hidden = true)
    public ResultData save(@RequestBody SysLog log){
        logService.save(log);
        return decide(Constant.INSERT);
    }

    @Operation(summary = "日志分页",description = "系统日志分页查询")
    @PostMapping("/list")
    public ResultData list(@RequestBody PageRequest<LogCriteria> request){
        return decide(logService.list(request));
    }

    @Operation(summary = "近15天日志统计",description = "系统日志查询近15天日志统计情况")
    @GetMapping("/lately")
    public ResultData lately(@RequestParam(required = false) String time){
        return decide(logService.lately(time));
    }
}
